package com.itany.corejava.code07_面向对象.bms;

/**
 * @author MissChen
 * @version 1.0
 * @date 2023 年11月07日 15:56
 */
public class LoanCreditAccount extends CreditAccount implements Loanable{
    private double loanAmount;//贷款金额

    public double getLoanAmount() {
        return loanAmount;
    }

    public void setLoanAmount(double loanAmount) {
        this.loanAmount = loanAmount;
    }


    /**
     * 贷款方法
     * @param money 贷款金额
     */
    @Override
    public void providerLoan(double money) {
        loanAmount+=money;
    }


    /**
     * 还款方法
     * @param money 还款金额
     * @return
     */
    @Override
    public boolean payLoan(double money) {
        if(getBalance()+getLimit()>=money){//1000+10000   5000
            setBalance(getBalance()-money);//还完钱后当前账户的余额
            loanAmount-=money;//还贷后当前贷款金额是多少
            return true;
        }

        return false;
    }


    /**
     * 查看当前贷款金额
     * @return
     */
    @Override
    public double queryLoan() {
        return loanAmount;
    }
}
